package com.yh.alert_yh;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
        dialog.setIcon(android.R.drawable.ic_dialog_info);
        dialog.setTitle("欢迎");// 可写在strings里面
        dialog.setMessage("欢迎使用本程序，请继续操作");
        dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface a0, int a1) {
                dialog.setTitle("FBI Warning！");
                dialog.setMessage("18岁以下未成年请自觉离开");
                dialog.setPositiveButton("未满18岁", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface a0, int a1) {
                        dialog.show();
                    }
                });
                dialog.setNegativeButton("我已经满18岁", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface a0, int a1) {

                    }
                });
                dialog.show();
            }
        });
        dialog.setNegativeButton("否定", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface a0, int a1) {

            }
        });
        dialog.create();
        dialog.show();
    }
}
